package com.flippy.fl.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.flippy.fl.events.*;
	import com.flippy.fl.model.FlippyModelLocator;
	import com.flippy.fl.model.Logger;
	import com.flippy.fl.model.Main;
	
	import flash.events.AsyncErrorEvent;
	import flash.events.NetStatusEvent;
	import flash.net.NetStream;

	public class QuestionStatusCommand implements ICommand
	{	
		[Bindable]	
		private var model:FlippyModelLocator = FlippyModelLocator.getInstance();		
		private var logger:Logger = model.logger;
		[Bindable]
		private var main:Main = model.main;
		private var mEvent:QuestionStatusEvent;		
		
		public function QuestionStatusCommand()
		{
			
		}

		public function execute(event:CairngormEvent):void
		{
			mEvent = event as QuestionStatusEvent;
			
			logger.logMessage( "question status command.. started: " + mEvent.enabled, this);												
			
			if (model.main.role == model.main.ROLE_AUTHOR) {			
				// event should be generated by enable/disable question button!
				model.main.questionEnabled = mEvent.enabled;
				
				// update RSO
				main.stateRSO.data["questionEnabled"] = mEvent.enabled;
				main.stateRSO.setDirty("questionEnabled"); 
			}
		}
		
				
	}
}
